//
//  UIImage+Extension.swift
//  MLWeiBo
//
//  Created by wenxing on 2017/1/12.
//  Copyright © 2017年 Se7venX. All rights reserved.
//

import UIKit

extension UIImage {

    
    
    class func snapImage() -> UIImage? {
        
        let window = UIApplication.shared.keyWindow!
        let wSize = window.bounds.size
        //1.开启上啊下文
        UIGraphicsBeginImageContextWithOptions(wSize, false, 1.0)
        //2.绘制
        window.drawHierarchy(in: window.bounds, afterScreenUpdates: true)
        
        //3.获取图片
        let image = UIGraphicsGetImageFromCurrentImageContext()
        
        //4.关闭上下文
        UIGraphicsEndImageContext()
        
        return image
    }



}


